// QuestID: 1021; Name: Roger's Apple; Map: 20000

void start_quest(Player @player, NPC @npc) {
	if (player.getQuest(1021) != 0) {
	    complete_quest(player, npc);
	} else {
	int state = npc.getState();
	if(state == 0) {
	if (player.getGender() == 0) {
	    npc.addText("Hey, Man~  What's up? Haha!  I am #p2000# who can teach you adorable new Maplers lots of information.");
		} else {
		npc.addText("Hey there, Pretty~ I am #p2000# who teaches you adorable new Maplers lots of information.");
		}
		npc.sendNext();
	}
	else if(state == 1) {
	if (player.getGender() == 0) {
	    npc.addText("You are asking who made me do this? Ahahahaha! Myself! I wanted to do this and just be kind to you new travellers.");
	} else {
		npc.addText("I know you are busy! Please spare me some time~ I can teach you some useful information! Ahahaha!");
		}
		npc.sendBackNext();
	}
	else if(state == 2) {
		npc.addText("So..... Let me just do this for fun! Abaracadabra~!");
		npc.sendAcceptDecline();
	}
	else if(state == 3) {
		if(npc.getSelected() == ACCEPT) {
			player.setHp(25);
			player.giveItem(2010007, 1);
			npc.addQuest(1021);
			npc.setState(npc.getState()+1);
			npc.addText("Surprised? If HP becomes 0, then you are in trouble. Now, I will give you #r#t2010007##k. Please take it. You will feel stronger. Open the Item window and double click to consume. Hey, It's very simple to open the Item window. Just press #bI#k on your keyboard.");
			npc.sendNext();
		}
		else{
		if (player.getGender() == 0) {
		    npc.addText("I can't believe an attractive guy like myself got turned down!");
		} else {
			npc.addText("I can't believe you just have turned down an attractive guy like me!");
		}
		npc.sendNext();
		npc.end();
		}
	}
	else if(state == 4) {
		npc.addText("Surprised? If HP becomes 0, then you are in trouble. Now, I will give you #r#t2010007##k. Please take it. You will feel stronger. Open the Item window and double click to consume. Hey, It's very simple to open the Item window. Just press #bI#k on your keyboard.");
		npc.sendNext();
	}
	else if(state == 5) {
		npc.addText("Please take all #t2010007#s that I gave you. You will be able to see the HP bar increasing. Please talk to me again when you recover your HP 100%."); 
		npc.sendBackOK();
	}
	}
}

void complete_quest(Player @player, NPC @npc) {
	int state = npc.getState();
	if(state == 0) {
		npc.addText("How easy is it to consume the item? Simple, right? You can set a #bhotkey#k on the right bottom slot. Haha you didn't know that! right? Oh, and if you are a beginer, HP will automatically recover itself as time goes by. Well it takes time but this is one of the strategies for the beginners.");
		npc.sendNext();
	}
	else if(state == 1) {
		npc.addText("Alright! Now that you have learned alot, I will give you a present. This is a must for your travle in Maple World, so thank me! Please use this under emergency cases!");
		npc.sendBackNext();
	}
	else if(state == 2) {
		npc.addText("Okay, this is all I can teach you. I know it's sad but it is time to say good bye. Well tack care of yourself and Good luck my friend!\r\n\r\n#fUI/UIWindow.img/QuestIcon/4/0#\r\n#v2010000# 3 #t2010000#\r\n#v2010009# 3 #t2010009#\r\n\r\n#fUI/UIWindow.img/QuestIcon/8/0# 10 EXP");	
		npc.sendBackNext();
	}
	else if(state == 3) {
		npc.endQuest(1021);
		player.giveItem(2010000, 3);
		player.giveItem(2010009, 3);
		player.giveExp(10);
		npc.end();	
	}
}